package com.mark.controller.backend;

import com.mark.common.ServerResponse;
import com.mark.pojo.HeadLine;
import com.mark.service.IHeadLineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by Choisaaaa on 2018/5/15.
 * Admin 对公告信息控制器的定义
 */

@Controller
@RequestMapping("/manage/headLine/")
public class HeadLineManageController {
    @Autowired
    private IHeadLineService iHeadLineService;

    //1.发布或者更新公告信息
    @RequestMapping(value = "save_headLine.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse headLineSave(HttpSession session, HeadLine headLine){
        return iHeadLineService.insertOrUpdate(headLine);
    }

    //2.获取公告信息列表
    @RequestMapping(value="list.do" , method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse getUserList(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
                                      @RequestParam(value = "pageSize",defaultValue = "10") int pageSize,
                                      HttpServletRequest httpServletRequest){
        return iHeadLineService.getHeadLineList(pageNum,pageSize);
    }

}
